<?php
class Login_Model extends CI_Model {
	protected $table_name = '';
	
	const GETADMINUSER_STMT = "CALL spGetUserForAdminLogin(?, ?)";
	const GETCUSTOMER_STMT = "CALL spGetCustomerForLogin(?, ?)";
	
	public function __construct() {
		$this->load->database();
	}
	
	/*
	Function to get user and role based on username and password from database
	for login into admin pages
	it will return username, password, role if username and password are correct
	otherwise it will return null
	*/
	public function get_admin_user($username, $password) {
		$params = array($username, $password);
		$query = $this->db->query(self::GETADMINUSER_STMT, $params);
		$result = $query->row_array();
		$query->next_result();
		$query->free_result();
		return $result;
	}
	
	public function get_customer($username, $password) {
		$params = array($username, $password);
		$query = $this->db->query(self::GETCUSTOMER_STMT, $params);
		$result = $query->row_array();
		$query->next_result();
		$query->free_result();
		return $result;		
	}
}
?>